package cn.ad.enumration;

import java.util.LinkedHashMap;
import java.util.Map;

public enum OsType {

	UNKOWN(0, "其它"), 
	ANDROID(1, "Android"), 
	IOS(2, "IOS"), 
	WINDOWS(3, "Windows");

	private int value;

	private String desc;

	private static java.util.HashMap<Integer, String> mappings;

	private synchronized static java.util.HashMap<Integer, String> getMappings() {
		if (mappings == null) {
			mappings = new LinkedHashMap<Integer, String>();
			for (OsType status : OsType.values()) {
				mappings.put(status.value, status.desc);
			}
		}
		return mappings;
	}

	private OsType(int value, String desc) {
		this.value = value;
		this.desc = desc;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public static String forValue(int value) {
		return getMappings().get(value);
	}
	
	 public static Map<Integer,String> getMapping(){
	        return getMappings();
	 }

}
